package org.railage.client.beans;

import java.util.Arrays;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;

import org.railage.common.dto.TicketOfUserDTO;
import org.railage.common.dto.UserDTO;
import org.railage.server.services.TicketService;

@ManagedBean(name = "boughtTickets")
@ViewScoped
public class BoughtTicketsBean {
	
	private TicketService ticketService = new TicketService();

	private List<TicketOfUserDTO> tickets = null;
	private UserDTO user = null;
	
	public BoughtTicketsBean() {
		user = (UserDTO) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get(AuthBean.SESSION_USER_PARAM);
		tickets = Arrays.asList(ticketService.getAllTicketsOfUser(user.getId()));
	}

	public List<TicketOfUserDTO> getTickets() {
		return tickets;
	}
	
}
